package xyz.xiangyushui.controller.membership.profile;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import xyz.xiangyushui.dao.user.member.MembershipProfileDao;

/**
 * Servlet implementation class MembershipProfile
 */
@WebServlet("/member/profile")
public class MembershipProfile extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private MembershipProfileDao mpd;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public MembershipProfile() {
        super();
        mpd=new MembershipProfileDao();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		xyz.xiangyushui.javaBean.membership.MembershipProfile mp=mpd.getProfile((String)request.getSession(false).getAttribute("userName"));
		request.setAttribute("userName", mp.getUserName());
		request.setAttribute("age",mp.getAge());
		request.setAttribute("gender",mp.getGender());
		request.setAttribute("address",mp.getAddress());
		request.getRequestDispatcher("/member/profile/index.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
